package com.luckyframe.project.jmeter.execution;

import com.luckyframe.project.jmeter.consumer.ErrorsGraphConsumer;
import com.luckyframe.project.jmeter.consumer.OverallStatisticsSummaryConsumer;
import org.apache.jmeter.report.processor.*;
import org.apache.jmeter.report.processor.graph.impl.*;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;


public class ResultDataParse {

    static {


    }

    public static List<AbstractSampleConsumer> graphConsumerList() {

        List<AbstractSampleConsumer> consumerList = new CopyOnWriteArrayList<>();
        Integer granularity = 1000;

        ActiveThreadsGraphConsumer activeThreadsGraphConsumer = new ActiveThreadsGraphConsumer();
        activeThreadsGraphConsumer.setGranularity(granularity);
        activeThreadsGraphConsumer.setName("activeThreads");
        activeThreadsGraphConsumer.initialize();
        consumerList.add(activeThreadsGraphConsumer);

        HitsPerSecondGraphConsumer hitsPerSecondGraphConsumer = new HitsPerSecondGraphConsumer();
        hitsPerSecondGraphConsumer.setGranularity(granularity);
        hitsPerSecondGraphConsumer.setName("hitsPerSecond");
        hitsPerSecondGraphConsumer.initialize();
        consumerList.add(hitsPerSecondGraphConsumer);


        ResponseTimeOverTimeGraphConsumer responseTimeOverTimeGraphConsumer = new ResponseTimeOverTimeGraphConsumer();
        responseTimeOverTimeGraphConsumer.setGranularity(granularity);
        responseTimeOverTimeGraphConsumer.setName("responseTimeOverTime");
        responseTimeOverTimeGraphConsumer.initialize();
        consumerList.add(responseTimeOverTimeGraphConsumer);


        TransactionsPerSecondGraphConsumer transactionsPerSecondGraphConsumer = new TransactionsPerSecondGraphConsumer();
        transactionsPerSecondGraphConsumer.setGranularity(granularity);
        transactionsPerSecondGraphConsumer.setName("tpsOverTime");
        transactionsPerSecondGraphConsumer.initialize();
        consumerList.add(transactionsPerSecondGraphConsumer);


        ErrorsGraphConsumer errorsGraphConsumer = new ErrorsGraphConsumer();
        errorsGraphConsumer.setGranularity(granularity);
        errorsGraphConsumer.setName("errors");
        errorsGraphConsumer.initialize();
        consumerList.add(errorsGraphConsumer);



        return consumerList;
    }


    public static List<AbstractSampleConsumer> caseWatchList() {

        List<AbstractSampleConsumer> consumerList = new CopyOnWriteArrayList<>();

        StatisticsSummaryConsumer overallStatisticsSummaryConsumer=new StatisticsSummaryConsumer();
        overallStatisticsSummaryConsumer.setName("overallStatistics");
        overallStatisticsSummaryConsumer.setHasOverallResult(false);
        consumerList.add(overallStatisticsSummaryConsumer);

        return consumerList;
    }

    public static List<AbstractSampleConsumer> planWatchList() {

        List<AbstractSampleConsumer> consumerList = new CopyOnWriteArrayList<>();

        OverallStatisticsSummaryConsumer overallStatisticsSummaryConsumer=new OverallStatisticsSummaryConsumer();
        overallStatisticsSummaryConsumer.setName("overallStatistics");
        overallStatisticsSummaryConsumer.setHasOverallResult(false);
        consumerList.add(overallStatisticsSummaryConsumer);

        return consumerList;
    }


}
